package com.example.administrator.express.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * Created by Administrator on 2016/9/14.
 */
@DatabaseTable(tableName = "users")
public class Users implements Parcelable {


    /**
     * adress : 都是
     * birthday : 1999-12-23 00:00:00
     * id : 1
     * loginId : 100
     * name : han
     * password : 123
     * phone : 112
     * picture : 12
     * role : {"roleId":1,"roleName":"经理"}
     * sex : 男
     */
    @DatabaseField(columnName = "adress")
    private String adress;
    @DatabaseField(columnName = "birthday")
    private String birthday;
    @DatabaseField(columnName = "id" ,generatedId = true)
    private int id;
    @DatabaseField(columnName = "loginId")
    private int loginId;
    @DatabaseField(columnName = "name")
    private String name;
    @DatabaseField(columnName = "password")
    private String password;
    @DatabaseField(columnName = "phone")
    private int phone;
    @DatabaseField(columnName = "picture")
    private String picture;

    /**
     * roleId : 1
     * roleName : 经理
     */

    @DatabaseField(canBeNull = true, foreign = true, columnName = "position",foreignAutoRefresh = true)
    private Role role;
    @DatabaseField(columnName = "sex")
    private String sex;

    public String getAdress() {
        return adress;
    }

    public void setAdress(String adress) {
        this.adress = adress;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getLoginId() {
        return loginId;
    }

    public void setLoginId(int loginId) {
        this.loginId = loginId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getPhone() {
        return phone;
    }

    public void setPhone(int phone) {
        this.phone = phone;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }



    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.adress);
        dest.writeString(this.birthday);
        dest.writeInt(this.id);
        dest.writeInt(this.loginId);
        dest.writeString(this.name);
        dest.writeString(this.password);
        dest.writeInt(this.phone);
        dest.writeString(this.picture);
        dest.writeParcelable(this.role, flags);
        dest.writeString(this.sex);
    }

    public Users() {
    }

    protected Users(Parcel in) {
        this.adress = in.readString();
        this.birthday = in.readString();
        this.id = in.readInt();
        this.loginId = in.readInt();
        this.name = in.readString();
        this.password = in.readString();
        this.phone = in.readInt();
        this.picture = in.readString();
        this.role = in.readParcelable(Role.class.getClassLoader());
        this.sex = in.readString();
    }

    public static final Parcelable.Creator<Users> CREATOR = new Parcelable.Creator<Users>() {
        @Override
        public Users createFromParcel(Parcel source) {
            return new Users(source);
        }

        @Override
        public Users[] newArray(int size) {
            return new Users[size];
        }
    };
}
